package com.zyz.M_File和IO流.IO流.转换流;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author: vick
 * @Date: 2025/4/10
 * @Description:
 * @version: 1.0
 */
public class Demo2 {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\14338\\Desktop\\file.txt");
        FileInputStream fileInputStream = new FileInputStream(file);
        //创建转换流, 默认UTF8编码
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "GBK");
        int charData;
        while ((charData = inputStreamReader.read()) != -1) {
            System.out.print((char) charData);
        }
        inputStreamReader.close();
    }
}
